//
// Created by songpingwang on 25-7-6.
//


#include <re2/re2.h>
#include <iostream>


int test_chinese_multi_groups() {
    const std::string text = "helle 正则表达式：测试结果test text is null，日期：2025-07-07";
    const RE2 pattern2(R"(正则表达式[:：]\s*([\x{4e00}-\x{9fa5}]+).*?日期[:：]\s*(\d{4}-\d{2}-\d{2}))");
    if (!pattern2.ok()) {
        std::cerr << "Regex compilation failed: " << pattern2.error() << std::endl;
        return 1;
    }

    // RE2::PartialMatch 的参数顺序(文本, 正则对象, &捕获组1, &捕获组2, ...)
    std::string result_text, date_str;
    if (RE2::PartialMatch(text, pattern2, &result_text, &date_str)) {
        // 期望输出 "Matched: 测试结果 日期: 2025-07-07"
        std::cout << "Matched: " << result_text << " 日期: " << date_str << std::endl;
    } else {
        std::cout << "Match failed!" << std::endl;
    }
    return 0;
}


int main() {
    test_chinese_multi_groups();
    return 0;

}